/// <reference types="vitest/config" />
import { fileURLToPath, URL } from 'node:url'

import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
import vueDevTools from 'vite-plugin-vue-devtools'

//配置组件自动注册的插件
//配置vant UI组件库的解析器
import Components from 'unplugin-vue-components/vite'
import { VantResolver } from 'unplugin-vue-components/resolvers'

//配置svg插件
import { createSvgIconsPlugin } from 'vite-plugin-svg-icons'
import path from 'path'
import { createHtmlPlugin } from 'vite-plugin-html'

// https://vite.dev/config/
export default defineConfig({
  server: {
    port: 80,
    host: true,
    allowedHosts: [
      "consult-patients.itheima.net", // 允许的域名
      "localhost"                     // 默认本地域名
    ]
  },
  test: {
    environment: 'happy-dom'
  },
  plugins: [
    createHtmlPlugin(),
    vue(),
    vueDevTools(),
    Components({
      dts: false,
      resolvers: [VantResolver({importStyle: false})]
    }),
    createSvgIconsPlugin({
      iconDirs: [path.resolve(process.cwd(), 'src/icons')]
    })
  ],
  resolve: {
    alias: {
      '@': fileURLToPath(new URL('./src', import.meta.url))
    },
  },
})
